package javagprssrv.DataAnalyse;

import javagprssrv.JGS_Param;
import javagprssrv.StructClass.structRecvData;

public class TrdDataAnalyse_DBAction extends java.lang.Thread
{
    javagprssrv.DataAnalyse.ScriptExecuter ScriptExecuter;
    javagprssrv.StructClass.structRecvData RecvData;
    java.lang.String RecvDataString;
    
    public TrdDataAnalyse_DBAction() {
        super("TrdDataAnalyse_DBAction");
        this.RecvData = new javagprssrv.StructClass.structRecvData();
        this.RecvDataString = "";
        try {
            this.ScriptExecuter = new javagprssrv.DataAnalyse.ScriptExecuter("DataReceiveAction.js");
        }
        catch (java.lang.Exception e) {
            e.printStackTrace();
        }
    }
    
    @java.lang.Override
    public void run() {
        while (true) {
            boolean isGetData = false;
            this.RecvDataString = "";
            synchronized (javagprssrv.JGS_Param.UnDoneDBActionRecvDatas) {
                if (javagprssrv.JGS_Param.UnDoneDBActionRecvDatas.size() > 0) {
                    isGetData = true;
                    this.RecvData = (structRecvData) javagprssrv.JGS_Param.UnDoneDBActionRecvDatas.remove(0);
                }
            }
            if (!isGetData) {
                try {
                    java.lang.Thread.sleep(50L);
                }
                catch (java.lang.Exception e) {}
            }
            else {
                javagprssrv.JGS_Param.setDataAnalyse_DBAction_BusyFlag(true);
                try {
                    java.lang.String S_SaveData = java.lang.String.valueOf(this.ScriptExecuter.Execute(4, "RecvDataType=" + this.RecvData.RecvDataType + ",RecvData=" + this.RecvData.Data));
                    S_SaveData = null;
                }
                catch (java.lang.Exception ex) {}
                javagprssrv.JGS_Param.setDataAnalyse_DBAction_BusyFlag(false);
            }
        }
    }
}
